package com.bjpowernode.crm.settings.service.impl;

import com.bjpowernode.crm.settings.dao.DicTypeDao;
import com.bjpowernode.crm.settings.dao.DicValueDao;
import com.bjpowernode.crm.settings.domain.DictionaryType;
import com.bjpowernode.crm.settings.domain.DictionaryValue;
import com.bjpowernode.crm.settings.service.DicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName:DicServiceImpl
 * package:com.bjpowernode.crm.settings.service.impl
 * Description:
 *
 * @date: 2022-05-28 2:26
 * @author：lin
 */
@Service
public class DicServiceImpl implements DicService {

    @Autowired
    private DicTypeDao dicTypeDao;

    @Autowired
    private DicValueDao dicValueDao;


    @Override
    public List<DictionaryType> getType() {
        List<DictionaryType> dicTypeDaoType = dicTypeDao.getType();


        return dicTypeDaoType;
    }

    @Override
    public boolean getTypeCode(String code) {

        boolean flag =true;

       int count  = dicTypeDao.getTypeCode(code);
       if (count!=0){
           flag=false;
       }

        return flag;
    }

    @Override
    public void saveType(DictionaryType type) {
        dicTypeDao.saveType(type);

    }

    @Override
    public DictionaryType toEdit(String code) {
        DictionaryType dictionaryType=dicTypeDao.toEdit(code);

        return dictionaryType;
    }

    @Override
    public void updateType(DictionaryType dictionaryType) {
        dicTypeDao.updateType(dictionaryType);

    }

    @Override
    public void deleteType(String[] codes) {
        dicValueDao.deleteType(codes);
        dicTypeDao.deleteType(codes);

    }

    @Override
    public List<DictionaryValue> selectValue() {
        List<DictionaryValue> DicValue= dicValueDao.selectValue();
        return DicValue;
    }

    @Override
    public void saveValue(DictionaryValue dictionaryValue) {
        dicValueDao.saveValue(dictionaryValue);
    }

    @Override
    public DictionaryValue selectValueId(String code) {
        DictionaryValue dicValue = dicValueDao.selectValueId(code);

        return dicValue;
    }

    @Override
    public void updateValue(DictionaryValue value) {

        dicValueDao.updateValue(value);
    }

    @Override
    public void deleteValue(String[] ids) {
        dicValueDao.deleteValue(ids);
    }

    @Override
    public List<DictionaryValue> searchDicValue(String typeCode) {

        return dicValueDao.searchDicValue(typeCode);
    }


}
